<?php
class AppController extends Controller {

        var $components = array('Session', 'Auth', 'AutoLogin', 'Cookie');

        function beforeFilter() {
//		Security::setHash('md5');
		Configure::write('Config.language', 'ru');

		$this->AutoLogin->cookieName = 'rhrnRemeberYou';
		$this->AutoLogin->expires = '+1 year';
		$this->AutoLogin->settings = array(
			'controller' => 'users',
			'loginAction' => 'login',
			'logoutAction' => 'logout'
		);

		$this->Cookie->key = 'cG!4tdfdv5hkjnRGkdu4eDVdw';

                $this->Auth->allow();

		$this->loadModel('Config');
		$conf =	$this->Config->get();
		if (!empty($conf)) {
			$this->layout = $conf['layout'];

			if ($conf['layout'] === 'lemuryru') {
			}
		}

		if ($user = $this->Auth->user()) {
			$uid	= $user['User']['id'];
			$login	= $user['User']['login'];
			if ($this->layout === 'lemuryru') {
				$this->loadModel('Message');
				$this->set('countMessage', $this->Message->countMessage($uid, 0));
			}
			$this->set('userLogin', $login);
		}
        }
}
?>
